<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>layui</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="../../layui-v2.4.3/layui/css/layui.css" media="all">
		<script src="../../js/jquery.js"></script>
		<script src="../../layui-v2.4.3/layui/layui.js"></script>
		<script src="../../js/jquery.cookie.js"></script>
		<script src="../../js/jquery.params.js"></script>
	</head>

	<body>
		<div class="layui-container" style="margin-top: 30px;">
			<table class="layui-hide" id="test" lay-filter="test"></table>
		</div>
		<script type="text/html" id="toolbarDemo">
			<div class="layui-inline">
				<select name="condition" id="queryCondition">
					<option value="1">学生学号</option>
					<!--<option value="2">学生班级</option>-->
				</select>
			</div>
			<div class="layui-inline">
				<input class="layui-input" id="queryContext">
			</div>
			<div class="layui-inline">
				<button class="layui-btn" lay-event="isAll">搜索</button>
			</div>
		</script>

		
		
		
		<script>
			$.ajax({
				type: "get",
				url: "http://localhost:8080/teacher/experiment/nothing.do",
				async: false,
				dataType: "json",
				data: {
					uid: $.cookie("uid")
				},
				success: function(data) {
					//alert(data.info);
					if(data.info == '404') {
						window.location.href = "../login/teacherlogin.html";
					}
				}
			});
			layui.use('table', function() {
				var table = layui.table;
				var con = {
					"context": "",
					"condition": ""
				}
				var couId = $.query.get("couId");
				var weight = $.query.get('weight');
				table.render({
					id: 'countScore',
					elem: '#test',
					toolbar: '#toolbarDemo',
					height: 500,
					page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
						layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
							,
						groups: 1 //只显示 1 个连续页码
							,
						limits: [10, 20, 30, 40, 50, 99999]
					},
					url: 'http://localhost:8080/teacher/course/calculate.do?couId=' + couId + "&weight=" + weight,
					where: {
						uid: $.cookie("uid"),
					},
					page: true //开启分页
						,
					cols: [
						[ //表头 
							{
								field: 'stuNum',
								title: '学号',
								sort: true,
								fixed: 'left'
							}, {
								field: 'stuName',
								title: '学生姓名'
							}, {
								field: 'couName',
								title: '学生班级',
								sort: true
							}, {
								field: 'allScore',
								title: '课程分数'
								
							}
						]
					]
				});

				table.on('toolbar(test)', function(obj) {
					var checkStatus = table.checkStatus(obj.config.id);
					switch(obj.event) {
						case 'isAll':
							con.condition = $("#queryCondition").val();
							con.context = $("#queryContext").val();
							//alert(queryCondition);
							//alert(queryContext);

							table.reload('countScore', {
								where: {
									uid: $.cookie("uid"),
									condition: $("#queryCondition").val(),
									context: $("#queryContext").val(),
								},
								page: {
									curr: 1,
								}
							});
							break;
					};
				});

			});
		</script>

	</body>

</html>